package com.cg.grpc.service;

import com.cg.grpc.Greeting;
import com.cg.grpc.HelloWorldServiceGrpc;
import com.cg.grpc.User;
import io.grpc.stub.StreamObserver;
import net.devh.boot.grpc.server.service.GrpcService;

@GrpcService
public class HelloWorldServiceImpl extends HelloWorldServiceGrpc.HelloWorldServiceImplBase {

    @Override
    public void sayHello(User request, StreamObserver<Greeting> responseObserver) {
        System.out.println("GrpcServer start...");

        Greeting greeting = Greeting.newBuilder().setMessage("Hello," + request.getUsername()).build();
        responseObserver.onNext(greeting);
        responseObserver.onCompleted();
    }
}
